/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * SpotDisplayFrame.java
 *
 * Created on Jul 29, 2011, 12:03:06 AM
 */
package client.parkingdisplay;

/**
 *
 * @author Team 5
 */
public class SpotDisplayFrame extends javax.swing.JFrame {

    private boolean action = false;
    private String ID = "";
    /** Creates new form SpotDisplayFrame */
    public SpotDisplayFrame() {
        initComponents();
    }
    /**
     * accessor
     * @return the ID input by the user
     */
    public String getID()
    {
        return ID;
    }
    /**
     * implements the Form interface that sets this screen 
     * invisible if an action is performed
     * @return true iff an action has been performed on the screen
     */
    synchronized public boolean displayNext()
    {
        if(action)
        {
            this.setVisible(false);
        }
        return action;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        spotNumberLabel = new javax.swing.JLabel();
        spotStatusLabel = new javax.swing.JLabel();
        scanID = new javax.swing.JButton();
        textField = new javax.swing.JTextField();
        spotType = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        spotNumberLabel.setFont(new java.awt.Font("Tahoma", 3, 20)); // NOI18N
        spotNumberLabel.setText("Parking Spot #");

        spotStatusLabel.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        spotStatusLabel.setText("Spot Status: ");

        scanID.setText("Scan ID");
        scanID.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                scanIDActionPerformed(evt);
            }
        });

        spotType.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        spotType.setText("Spot Type:");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(113, 113, 113)
                        .addComponent(spotNumberLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 154, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(63, 63, 63)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(spotStatusLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(scanID)
                                .addGap(41, 41, 41)
                                .addComponent(textField, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(spotType, javax.swing.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE))))
                .addContainerGap(133, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addComponent(spotNumberLabel)
                .addGap(52, 52, 52)
                .addComponent(spotStatusLabel)
                .addGap(28, 28, 28)
                .addComponent(spotType)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 40, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(scanID)
                    .addComponent(textField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(74, 74, 74))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void scanIDActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_scanIDActionPerformed
        // TODO add your handling code here:
        ID = textField.getText();
        action = true;
    }//GEN-LAST:event_scanIDActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new SpotDisplayFrame().setVisible(true);
            }
        });
    }
    
    /**
     * updates the text named spotStatusLabel
     * @param stat contains the new message to be displayed
     */
    public void updateStatus(String stat)
    {
        spotStatusLabel.setText(stat);
    }
    /**
     * updates the text named spotNumberLabel
     * @param stat contains the new message to be displayed
     */
    public void updateNumber(String stat)
    {
        spotNumberLabel.setText(stat);
    }
    /**
     * updates the text named spotType
     * @param stat contains the new message to be displayed
     */
    public void updateType(String stat)
    {
        spotType.setText(stat);
    }
    
    public void ScanID(String id)
    {
    	textField.setText(id);
    	scanID.doClick();
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton scanID;
    private javax.swing.JLabel spotNumberLabel;
    private javax.swing.JLabel spotStatusLabel;
    private javax.swing.JLabel spotType;
    private javax.swing.JTextField textField;
    // End of variables declaration//GEN-END:variables
}
